﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Maticsoft.DBUtility;
using System.Windows.Forms;

namespace DataServer
{
    /// <summary>
    /// 系统用户操作类
    /// </summary>
    public class SysUserOpts
    {
        public DataTable GetUserList(out OptsModel optsmodel)
        {
            optsmodel = new OptsModel();
            DataTable dt=null;
            try
            {
                string sql = "select * from tbMobilUsr";
                dt = DbHelperSQL.Query(sql).Tables[0];
                optsmodel.Succeed = true;
            }
            catch (Exception e) {
                optsmodel.ExceptionMsg = "加载系统用户出现异常:" + e.Message;                
            }

            return dt;
        }
        public void SetListViewData(DataTable dt,ListView lstUserList) {
            ListViewItem lstItem;
            int rows = 1;
            foreach (DataRow row in dt.Rows) {
                lstItem = new ListViewItem();
                lstItem.SubItems[0].Text = rows + "";
                lstItem.SubItems.Add(row["usrName"].ToString().Trim());
                lstItem.SubItems.Add(row["usrPWD"].ToString().Trim());
                lstItem.SubItems.Add(row["Permission"].ToString().Trim());
                lstItem.SubItems.Add(row["groupName"].ToString().Trim());
                lstItem.SubItems.Add(row["reMark"].ToString().Trim());
                lstUserList.Items.Add(lstItem);
                rows++;
            }
        }
    }
}
